#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "prescheme.h"

char *string_append(char*, char*);
long main(long, char**);


char *string_append(char *a_0X, char *b_1X)
{
  long arg0K1;
  long arg0K0;
  long src_8X;
  long tgt_7X;
  long src_6X;
  long tgt_5X;
  char *target_4X;
  long len_b_3X;
  long len_a_2X;
 {  len_a_2X = strlen((char *) a_0X);
  len_b_3X = strlen((char *) b_1X);
  target_4X = (char *)calloc( 1, 1 + (len_a_2X + len_b_3X));
  arg0K0 = 0;
  arg0K1 = 0;
  goto L66;}
 L66: {
  tgt_5X = arg0K0;
  src_6X = arg0K1;
  if ((src_6X == len_a_2X)) {
    arg0K0 = len_a_2X;
    arg0K1 = 0;
    goto L84;}
  else {
    *(target_4X + tgt_5X) = (*(a_0X + src_6X));
    arg0K0 = (1 + tgt_5X);
    arg0K1 = (1 + src_6X);
    goto L66;}}
 L84: {
  tgt_7X = arg0K0;
  src_8X = arg0K1;
  if ((src_8X == len_b_3X)) {
    return target_4X;}
  else {
    *(target_4X + tgt_7X) = (*(b_1X + src_8X));
    arg0K0 = (1 + tgt_7X);
    arg0K1 = (1 + src_8X);
    goto L84;}}
}
long main(long argc_9X, char **argv_10X)
{
  long arg0K1;
  long arg0K0;
  FILE * merged_arg2K2;
  char *merged_arg1K1;
  char *merged_arg1K0;

#ifdef USE_DIRECT_THREADING
  void *demo_string_append_return_address;
#else
  int demo_string_append_return_tag;
#endif
  char demo_string_append0_return_value;
  char *a_11X;
  char *b_12X;
  FILE * out_13X;
  long src_24X;
  long tgt_23X;
  long src_22X;
  long tgt_21X;
  char *target_20X;
  long len_b_19X;
  long len_a_18X;
  FILE * out_17X;
  char *b_16X;
  char *a_15X;
  FILE * out_14X;
 {  if ((3 == argc_9X)) {
    out_14X = stdout;
    a_15X = *(argv_10X + 1);
    b_16X = *(argv_10X + 2);
    merged_arg1K0 = a_15X;
    merged_arg1K1 = a_15X;
    merged_arg2K2 = out_14X;
#ifdef USE_DIRECT_THREADING
    demo_string_append_return_address = &&demo_string_append_return_0;
#else
    demo_string_append_return_tag = 0;
#endif
    goto demo_string_append;
   demo_string_append_return_0:
    merged_arg1K0 = a_15X;
    merged_arg1K1 = b_16X;
    merged_arg2K2 = out_14X;
#ifdef USE_DIRECT_THREADING
    demo_string_append_return_address = &&demo_string_append_return_1;
#else
    demo_string_append_return_tag = 1;
#endif
    goto demo_string_append;
   demo_string_append_return_1:
    merged_arg1K0 = b_16X;
    merged_arg1K1 = b_16X;
    merged_arg2K2 = out_14X;
#ifdef USE_DIRECT_THREADING
    demo_string_append_return_address = &&demo_string_append_return_2;
#else
    demo_string_append_return_tag = 2;
#endif
    goto demo_string_append;
   demo_string_append_return_2:
    return 0;}
  else {
    out_17X = stderr;
    ps_write_string("Usage: ", out_17X);
    ps_write_string((*(argv_10X + 0)), out_17X);
    ps_write_string(" <string-a> <string-b>", out_17X);
    { long ignoreXX;
    PS_WRITE_CHAR(10, out_17X, ignoreXX) }
    ps_write_string("  Prints permutations of <string-a> and <string-b>.", out_17X);
    { long ignoreXX;
    PS_WRITE_CHAR(10, out_17X, ignoreXX) }
    return 1;}}
 demo_string_append: {
  a_11X = merged_arg1K0;
  b_12X = merged_arg1K1;
  out_13X = merged_arg2K2;{
  len_a_18X = strlen((char *) a_11X);
  len_b_19X = strlen((char *) b_12X);
  target_20X = (char *)calloc( 1, 1 + (len_a_18X + len_b_19X));
  arg0K0 = 0;
  arg0K1 = 0;
  goto L121;}
 L121: {
  tgt_21X = arg0K0;
  src_22X = arg0K1;
  if ((src_22X == len_a_18X)) {
    arg0K0 = len_a_18X;
    arg0K1 = 0;
    goto L131;}
  else {
    *(target_20X + tgt_21X) = (*(a_11X + src_22X));
    arg0K0 = (1 + tgt_21X);
    arg0K1 = (1 + src_22X);
    goto L121;}}
 L131: {
  tgt_23X = arg0K0;
  src_24X = arg0K1;
  if ((src_24X == len_b_19X)) {
    ps_write_string(target_20X, out_13X);
    { long ignoreXX;
    PS_WRITE_CHAR(10, out_13X, ignoreXX) }
    free(target_20X);
    demo_string_append0_return_value = 1;
#ifdef USE_DIRECT_THREADING
    goto *demo_string_append_return_address;
#else
    goto demo_string_append_return;
#endif
}
  else {
    *(target_20X + tgt_23X) = (*(b_12X + src_24X));
    arg0K0 = (1 + tgt_23X);
    arg0K1 = (1 + src_24X);
    goto L131;}}
#ifndef USE_DIRECT_THREADING
 demo_string_append_return:
  switch (demo_string_append_return_tag) {
  case 0: goto demo_string_append_return_0;
  case 1: goto demo_string_append_return_1;
  default: goto demo_string_append_return_2;
  }
#endif
}

}
